package com.example.demo.service;

import javax.annotation.Resource;

import com.example.demo.event.DemoTestEvent;

import org.springframework.context.ApplicationContext;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TestServiceImpl implements TestService{
  @Resource
  private ApplicationContext ac;
  @Override
  public String test() {
    log.info(">>>>>test Service test() threadName:{}", Thread.currentThread().getName());
    // 因为使用的是jdk动态代理自定义实例化该类，【@Bean】，此处运行pulishEvent会报异常
    ac.publishEvent(new DemoTestEvent(this, "Service.test()"));
    return "test";
  }
    
}